import request from "@/utils/request";
import { DeptForm, DeptQuery } from "./types";

// 查询部门列表
export const listDept = (query?: DeptQuery) => {
  return request({
    url: "/budget-dept/page",
    method: "post",
    data: query
  });
};

// 查询部门详细
export const getDept = (deptId: string | number) => {
  return request({
    url: "/budget-dept/" + deptId,
    method: "get"
  });
};


// 新增部门
export const addDept = (data: DeptForm) => {
  return request({
    url: "/budget-dept",
    method: "post",
    data: data
  });
};

// 修改部门
export const updateDept = (data: DeptForm) => {
  return request({
    url: "/budget-dept",
    method: "put",
    data: data
  });
};

// 删除部门
export const delDept = (deptId: number | string) => {
  return request({
    url: "/budget-dept/" + deptId,
    method: "delete"
  });
};

//修改状态
export const updateStatusById = (deptId: number, type: number, status: boolean) => {
  return request({
    url: "/budget-dept/updateStatus?deptId=" + deptId + "&type=" + type + "&status=" + status,
    method: "get"
  });
};

export const getDeptList = (type: number) => {
  return request({
    url: "/budget-dept/getList/" + type,
    method: "get"
  });
};


